<?php
require_once "config.php";

$catename = $_POST['cate_name'];
$flag = $_POST['level'];
$time = time();
if($catename!=""){
    $sql = "insert into category(cate_name,flag,time) value('{$catename}',$flag,$time)";
    $rst = mysqli_query($con,$sql);
    $id = mysqli_insert_id($con);
    if($id){
        echo "<script>alert('插入成功!');window.location.href='cate_list.php';</script>";
    }else{
        echo "<script>alert('插入失败,请重新输入');window.location.href='cate_add.php';</script>";
    }
}else{
    echo "<script>alert('类型不能为空,请重新输入');window.location.href='cate_add.php';</script>";
}